package com.hs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.dto.PriceRule;
import com.hs.mapper.PriceRuleMapper;
import com.hs.service.PriceRuleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PriceRuleServiceImpl extends ServiceImpl<PriceRuleMapper, PriceRule> implements PriceRuleService {

    @Resource
    private PriceRuleMapper priceRuleMapper;

    @Override
    public PageInfo<PriceRule> selectPriceRuleList(Integer pageNum, String keywords) {
        PageHelper.startPage(pageNum,3);

        QueryWrapper<PriceRule> queryWrapper = new QueryWrapper<>();

        if (keywords != null && !keywords.isEmpty()) {
            queryWrapper.like("rule_name", keywords);  // 根据用户名进行模糊查询
        }

        List<PriceRule> priceRuleList = priceRuleMapper.selectList(queryWrapper);
        return new PageInfo<>(priceRuleList);
    }


}